package com.xiaoyi.sports.service.convert;

import java.util.List;

import com.xiaoyi.sports.data.entity.UserInfo;
import com.xiaoyi.sports.data.entity.UserInfoExample;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;

import com.xiaoyi.sports.service.dto.CreateUserInfoReqTO;
import com.xiaoyi.sports.service.dto.DeleteUserInfoReqTO;
import com.xiaoyi.sports.service.dto.ModifyUserInfoReqTO;
import com.xiaoyi.sports.service.dto.QueryUserInfoBeanTO;
import com.xiaoyi.sports.service.dto.QueryUserInfoReqTO;
import com.xiaoyi.sports.service.dto.QueryUserInfoResTO;

public class UserInfoPOConvertor {
	
	public static UserInfo convertCreateSampleDO(CreateUserInfoReqTO to){
		UserInfo entity = new UserInfo();
		BeanUtils.copyProperties(to, entity);
		return entity;
	}
	
	public static UserInfo convertModifySampleDO(ModifyUserInfoReqTO to){
		UserInfo entity = new UserInfo();
		BeanUtils.copyProperties(to, entity);
		return entity;
	}
	
	public static UserInfoExample convertDeleteSampleDO(DeleteUserInfoReqTO to){
		UserInfoExample entity = new UserInfoExample();
		BeanUtils.copyProperties(to, entity);
		return entity;
	}
	
	public static UserInfoExample convertQuerySampleDO(QueryUserInfoReqTO to){
		UserInfoExample entity = new UserInfoExample();
		BeanUtils.copyProperties(to, entity);
		return entity;
	}
	
	public static QueryUserInfoResTO convertQuerySampleTO(List<UserInfo> dos){
		QueryUserInfoResTO rst = new QueryUserInfoResTO();
		
		if(CollectionUtils.isNotEmpty(dos)){
			for(UserInfo entity : dos){
				QueryUserInfoBeanTO to = new QueryUserInfoBeanTO();
				BeanUtils.copyProperties(entity, to);
				rst.getResultList().add(to);
			}
		}
		
		return rst;
	}

}
